package com.ruoyi.project.yuwen.audiototal.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.yuwen.audiototal.domain.AudioTotal;
import com.ruoyi.project.yuwen.audiototal.mapper.AudioTotalMapper;
import com.ruoyi.project.yuwen.audiototal.service.IAudioTotalService;
import com.ruoyi.project.yuwen.kkuserInfo.mapper.KYuwenkuserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 朗诵统计Service业务层处理
 *
 * @author shixiangwen
 * @date 2021-04-26
 */
@Service
@DataSource(DataSourceType.KKCUSER)
public class AudioTotalServiceImpl implements IAudioTotalService {
    @Autowired
    private AudioTotalMapper audioTotalMapper;

    @Autowired
    private KYuwenkuserInfoMapper kkuserInfoMapper;

    /**
     * 查询朗诵统计
     *
     * @param id 朗诵统计ID
     * @return 朗诵统计
     */
    @Override
    public AudioTotal selectAudioTotalById(Long id) {
        return audioTotalMapper.selectAudioTotalById(id);
    }

    /**
     * 查询朗诵统计列表
     *
     * @param audioTotal 朗诵统计
     * @return 朗诵统计
     */
    @Override
    public List<AudioTotal> selectAudioTotalList(AudioTotal audioTotal) {
        List<AudioTotal> list = audioTotalMapper.selectAudioTotalList(audioTotal);
        list.forEach(item -> {
            item.setUser(kkuserInfoMapper.selectKkuserInfoById(item.getKkuid()));
        });
        return list;
    }

    /**
     * 新增朗诵统计
     *
     * @param audioTotal 朗诵统计
     * @return 结果
     */
    @Override
    public int insertAudioTotal(AudioTotal audioTotal) {
        return audioTotalMapper.insertAudioTotal(audioTotal);
    }

    /**
     * 修改朗诵统计
     *
     * @param audioTotal 朗诵统计
     * @return 结果
     */
    @Override
    public int updateAudioTotal(AudioTotal audioTotal) {
        return audioTotalMapper.updateAudioTotal(audioTotal);
    }

    /**
     * 删除朗诵统计对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteAudioTotalByIds(String ids) {
        return audioTotalMapper.deleteAudioTotalByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除朗诵统计信息
     *
     * @param id 朗诵统计ID
     * @return 结果
     */
    @Override
    public int deleteAudioTotalById(Long id) {
        return audioTotalMapper.deleteAudioTotalById(id);
    }
}
